﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tigera.T_Definition;

namespace Plugin.TradeSharp.UserControls
{
    public partial class UCRiskSettingRule4 : UserControl
    {
        public UCRiskSettingRule4()
        {
            InitializeComponent();
        }
        public string Title
        {
            get
            {
                return "期货风控设置";
            }
        }
        public RiskFutureLimit AllowFutureSetting
        {
            get
            {
                RiskFutureLimit ret = new RiskFutureLimit();

                ret.InvestLimitInFuture = (string.IsNullOrEmpty(this.textBox_InvestLimitInFuture.Text) ? 0 : double.Parse(this.textBox_InvestLimitInFuture.Text) ) /100;
                ret.InvestLimitInTotal = (string.IsNullOrEmpty(this.textBox_InvestLimitInTotal.Text) ? 0 : double.Parse(this.textBox_InvestLimitInTotal.Text) )/100;
                ret.ShortLimit = (string.IsNullOrEmpty(this.textBox_ShortLimit.Text) ? 0 : double.Parse(this.textBox_ShortLimit.Text))/100;
                ret.MoreLimit = (string.IsNullOrEmpty(this.textBox_MoreLimit.Text) ? 0 : double.Parse(this.textBox_MoreLimit.Text))/100;

                return ret;
            }
            set
            {
                this.textBox_InvestLimitInFuture.Text = (value.InvestLimitInFuture*100).ToString();
                this.textBox_InvestLimitInTotal.Text = (value.InvestLimitInTotal*100).ToString();
                this.textBox_ShortLimit.Text =  (value.ShortLimit*100).ToString();
                this.textBox_MoreLimit.Text = (value.MoreLimit*100).ToString();
            }
        }
    }
}
